package com.pro.service.imple;

import com.pro.mapper.JsUserMapper;
import com.pro.pojo.*;
import com.pro.service.JsUserService;
import com.pro.utils.DateUtils;
import com.pro.utils.RedisCatch;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 *
 * @author MYH - SiYun
 * @date 2022/1/6 16:33
 */

@Service
public class JsUserServiceImple implements JsUserService {

    @Autowired
    private JsUserMapper jsUserMapper;
    @Autowired
    private RedisCatch redisCatch;
    @Override
    public JsUser getUser(String accout, String password) {
        return jsUserMapper.getUser(accout,password);
    }

    @Override
    public JsUser getAccount(String account) {
        return jsUserMapper.getAccount(account);
    }

    @Override
    public List<JsUser> getUserList(JsUser jsUser) {
        return jsUserMapper.getUserList(jsUser);
    }

    @Override
    public List<JsUser> getUserListRetrieval(JsUser jsUser) {
        return jsUserMapper.getUserListRetrieval(jsUser);
    }

    @Override
    public boolean updateJsUserEnabled(Integer userId,Integer enabled) {
        return jsUserMapper.updateJsUserEnabled(userId,enabled);
    }

    @Override
    public boolean updateJsUserStatus(Integer userId,Integer status) {
        return jsUserMapper.updateJsUserStatus(userId,status);
    }

    @Override
    public boolean updateJsUser(JsUser jsUser) {
        return jsUserMapper.updateJsUser(jsUser);
    }

    @Override
    public List<Integer> getJsUserPower(Integer userId) {
        return jsUserMapper.getJsUserPower(userId);
    }

    @Override
    public boolean deleteJsUserPower(Integer userId) {
        return jsUserMapper.deleteJsUserPower(userId);
    }

    @Override
    public boolean addJsUserPower(JsRoleAuthority jsRoleAuthority) {
        return jsUserMapper.addJsUserPower(jsRoleAuthority);
    }

    @Override
    public List<JsDept> getJsDept() {
        return jsUserMapper.getJsDept();
    }

    @Override
    public List<JsDept> getJsUserById(Integer id) {
        return jsUserMapper.getJsUserById(id);
    }

    @Override
    public boolean updateJsDeptNameById(Integer id,String deptName) {
        return jsUserMapper.updateJsDeptNameById(id,deptName);
    }

    @Override
    public boolean deleteJsDeptById(Integer id) {
        return jsUserMapper.deleteJsDeptById(id);
    }

    @Override
    public boolean importJsUser(List<JsUser> jsUser) {
        return jsUserMapper.importJsUser(jsUser);
    }

    @Override
    public List<String> getJsUserAccount() {
        return jsUserMapper.getJsUserAccount();
    }

    @Override
    public boolean addJsUser(JsUser jsUser) {
        return jsUserMapper.addJsUser(jsUser);
    }

    @Override
    public Integer getJsUserByAccount(String account) {
        return jsUserMapper.getJsUserByAccount(account);
    }

    @Override
    public boolean addJsUserDept(Integer userId,Integer deptId) {
        return jsUserMapper.addJsUserDept(userId,deptId);
    }

    @Override
    public List<JsUnseal> getJsUnseal(JsUnseal jsUnseal) {
        return jsUserMapper.getJsUnseal(jsUnseal);
    }

    @Override
    public boolean deleteJsUnseal(Integer id) {
        return jsUserMapper.deleteJsUnseal(id);
    }

    @Override
    public List<JsDept> getJsDeptList(JsDept jsDept) {
        return jsUserMapper.getJsDeptList(jsDept);
    }

    @Override
    public boolean updateJsDeptStatus(Integer id, Integer status) {
        return jsUserMapper.updateJsDeptStatus(id,status);
    }

    @Override
    public boolean updateJsDept(JsDept jsDept) {
        return jsUserMapper.updateJsDept(jsDept);
    }

    @Override
    public List<JsLoginRecord> getBackStageLogin(JsLoginRecord jsLoginRecord) {
        return jsUserMapper.getBackStageLogin(jsLoginRecord);
    }

    @Override
    public boolean deleteLoginRecord(Integer id) {
        return jsUserMapper.deleteLoginRecord(id);
    }
    /**
     * @Author 祖铭泽
     * @Date 2022/2/22/0022
     * @description 为用户添加部门
     */
    @Override
    public boolean addUsersDept(List<JsUser> jsUsers) {
        return jsUserMapper.addUsersDept(jsUsers);
    }
    /**
     * @Author 祖铭泽
     * @Date 2022/2/23/0022
     * @description 添加部门
     */
    @Override
    public JsonData addDept(JsDept dept) {
        dept.setCreateDate(DateUtils.tranferDateTimeToString(new Date()));
        boolean addDept = jsUserMapper.addDept(dept);
        boolean deptTree = redisCatch.deleteObject("deptTree");
        return addDept && deptTree ? JsonData.buildSuccess(dept) : JsonData.buildError("添加失败");
    }
    /**
     * @Author 祖铭泽
     * @Date 2022/2/27/0022
     * @description 根据账号获取id
     */
    @Override
    public Integer getUserIdByAccount(String account) {
        return jsUserMapper.getUserIdByAccount(account);
    }

}
